<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	ArrayList<String> jsPaths = (ArrayList<String>) request
			.getAttribute("jsPaths");
	jsPaths.add("/resources/bootstrap/table/jquery.dataTables.min.js");
	jsPaths.add("/resources/bootstrap/table/dataTables.bootstrap.js");
	jsPaths.add("/resources/custom/user/user.js");
	jsPaths.add("/resources/bootstrap/dynatree/jquery-ui.custom.js");
	jsPaths.add("/resources/bootstrap/dynatree/jquery.cookie.js");
	jsPaths.add("/resources/bootstrap/dynatree/jquery.dynatree.js");
%>
<div class="row">
	<h2 class="sub-header">登录管理</h2>
	<button class="btn btn-success btn-sm" id="addUser">添加系统用户</button>
</div>
<div class="row top"></div>
<div class="row">
	<div class="table-responsive">
		<table class="table table-striped table-hover" id="user">
			<thead>
				<tr>
					<th>ID</th>
					<th>用户名</th>
					<th>昵称</th>
					<th>创建时间</th>
					<th>系统角色</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
			</tbody>
		</table>
	</div>
</div>

<!-- add user dialog -->
<div class="modal fade" id="createUserModal" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">添加系统用户</h4>
			</div>

			<form id="addForm" class="form-horizontal" role="form"
				action="${pageContext.request.contextPath}/user/create"
				method="post">
				<div class="modal-body">
					<div class="form-group">
						<label for="username" class="col-sm-3 control-label">用户名</label>
						<div class="col-sm-9">
							<input type="text" class="form-control" id="username"
								name="username" placeholder="用户名" />
						</div>
					</div>
					<div class="form-group">
						<label for="nickname" class="col-sm-3 control-label">昵称</label>
						<div class="col-sm-9">
							<input type="text" class="form-control" id="nickname"
								name="nickname" placeholder="昵称" />
						</div>
					</div>
					<div class="form-group">
						<label for="roleList" class="col-sm-3 control-label">角色</label>
						<div class="col-sm-9">
							<div class="dropdown">
								<button id="addDropDownBtn" type="button"
									class="btn btn-default dropdown-toggle" data-toggle="dropdown">
								</button>
								<input type="hidden" id="roleId" name="roleId" />
								<ul id="add-menu" class="dropdown-menu user" role="menu"
									aria-labelledby="roleName">
								</ul>
							</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="submit" class="btn btn-primary">创建用户</button>
				</div>
			</form>
		</div>
	</div>
</div>
<!-- edit user dialog -->
<div class="modal fade" id="editUserModal" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">编辑系统用户</h4>
			</div>
			<form id="editForm" class="form-horizontal" role="form"
				action="${pageContext.request.contextPath}/user/update"
				method="post">
				<div class="modal-body">
					<input type="hidden" id="idE" name="id">
					<div class="form-group">
						<label for="username" class="col-sm-3 control-label">用户名</label>
						<div class="col-sm-9">
							<input type="text" class="form-control" id="usernameE"
								name="username" placeholder="User Name" />
						</div>
					</div>
					<div class="form-group">
						<label for="nickname" class="col-sm-3 control-label">昵称</label>
						<div class="col-sm-9">
							<input type="text" class="form-control" id="nicknameE"
								name="nickname" placeholder="Nick Name" />
						</div>
					</div>
					<div class="form-group">
						<label for="roleList" class="col-sm-3 control-label">角色</label>
						<div class="col-sm-9">
							<div class="dropdown">
								<button id="editDropDownBtn" type="button"
									class="btn btn-default dropdown-toggle" data-toggle="dropdown">
								</button>
								<input type="hidden" id="roleIdE" name="roleId" />
								<ul id="edit-menu" class="dropdown-menu user" role="menu"
									aria-labelledby="roleName">
								</ul>

							</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="submit" class="btn btn-primary">保存用户</button>
				</div>
			</form>
		</div>
	</div>
</div>

<!-- delete user dialog -->
<div class="modal fade" id="deleteUserModal">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>
				<h4 class="modal-title">删除系统用户</h4>
			</div>
			<div class="modal-body">
				<p>确定永久删除该系统用户?</p>
			</div>
			<form class="form-horizontal" role="form"
				action="${pageContext.request.contextPath}/user/delete"
				method="post">
				<input type="hidden" id="idD" name="id">
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="submit" class="btn btn-primary">删除</button>
				</div>
			</form>
		</div>
	</div>
</div>
<!-- control user dialog -->
<div class="modal fade" id="controlUserModal" tabindex="-1"
	role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">为项目经理用户赋权限</h4>
			</div>

			<form id="controlForm" class="form-horizontal" role="form"
				action="${pageContext.request.contextPath}/user/control"
				method="post">
				<div class="modal-body">
					<div class='form-group'>
						<div id='tree' class='tree'></div>
					</div>
					<div class="form-group">
						<label for="projectName" class="col-sm-3 control-label">项目名称</label>
						<div class="col-sm-9">
							<textarea class="form-control" id="projectName" rows="3"
								name="projectName" placeholder="项目名称" disabled></textarea>
						</div>
					</div>
					<input type='hidden' id='projectId' name='projectId'> <input
						type='hidden' id='userIdControl' name='userId'>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						<button type="submit" class="btn btn-primary">保存</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>

<!-- reset user dialog -->
<div class="modal fade" id="resetUserModal">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>
				<h4 class="modal-title">重置系统用户密码</h4>
			</div>
			<div class="modal-body">
				<p>确认重置该系统用户密码？</p>
			</div>
			<form class="form-horizontal" role="form"
				action="${pageContext.request.contextPath}/user/reset" method="post">
				<input type="hidden" id="idR" name="id">
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="submit" class="btn btn-primary">重置</button>
				</div>
			</form>
		</div>
	</div>
</div>
